/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "core/结构数据.h"




template<typename T>
struct S_2DKDTree {
	S_KDTree*	m_子节点[4];
	vec2		m_原点;
	std::set<T>	m_数据;

	S_2DKDTree(vec2 原点) {
		for (uint32 i = 0; i < 4; ++i) {
			m_子节点[i] = nullptr;
		}
		m_原点 = 原点;

	}
	~S_球形四叉树() {
		for (uint32 i = 0; i < 4; ++i) {
			if(m_子节点[i]) delete m_子节点[i];
		}
	}


	void f_add(T data, vec2 coord, vec2 跨度) {
		auto 创建新树 = [&](uint32 id)->S_2DKDTree<T>*{
			if(!m_子节点[id]) m_子节点[id] = new S_2DKDTree();
		};
		if (coord.x >= m_原点.x) {
			if (coord.y >= m_原点.y) {
				创建新树(3);

				vec2 k = coord - m_原点;
				if (kx.x > 跨度.x) {
					
				}
			}
			else {
				m_子节点[1];
			}
		}
		else {
			if (coord.y >= m_跨度.y) {
				m_子节点[2];
			}
			else {
				m_子节点[0];
			}
		}
	}

	void f_mov(vec2 coord) {
		if (coord.x >= m_跨度.x) {
			if (coord.y >= m_跨度.y) {
				m_子节点[3];
			}
			else {
				m_子节点[1];
			}
		}
		else {
			if (coord.y >= m_跨度.y) {
				m_子节点[2];
			}
			else {
				m_子节点[0];
			}
		}
	}
};








